const gulp = require('gulp');
const browserSync = require('browser-sync');
const proxyGulpMiddlearea = require('http-proxy-middleware')

function proxyMiddleware(config){
  return Object.keys(config).map(el=>{
    return proxyGulpMiddlearea(el,config[el])
  })
}

const proxy = {
    '/v1/': {
        target: 'https://dev.snaily.com.cn',
        changeOrigin: true,
        logLevel: 'debug',
    },
}

const webConfig = {
    port: 3000,
    server: {
        baseDir: "./static/"
    },
    middleware: proxyMiddleware(proxy)
};

gulp.task('dev', function () {
    browserSync.init(webConfig);
});